package com.aaa.service.systemmanage.impl;

import com.aaa.aspect.InsertAnn;
import com.aaa.aspect.UpdateAnn;
import com.aaa.dao.systemmanage.RoleDao;
import com.aaa.entity.PageSortEntity;
import com.aaa.entity.systemmanage.Role;
import com.aaa.service.systemmanage.RoleService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 角色信息表(Role)表服务实现类
 *
 * @author makejava
 * @since 2022-08-31 16:00:14
 */
@Service("roleService")
public class RoleServiceImpl implements RoleService {
    @Resource
    private RoleDao roleDao;


    @Override
    public Page queryAll(PageSortEntity pageSortEntity, Role role) {
        //分页
        PageHelper.startPage(pageSortEntity.getPage(), pageSortEntity.getLimit(), pageSortEntity.getOrderString());
        List<Role> roles = roleDao.queryAll(role);
        Page pageResult = (Page) roles;
        return pageResult;
    }

    @Override
    public List<Role> queryAllToSelect() {
        return roleDao.queryAllToSelect();
    }

    /**
     * 新增数据
     *
     * @param role 实例对象
     * @return 实例对象
     */
    @InsertAnn
    @Override
    public Role insert(Role role) {
        roleDao.insert(role);
        return role;
    }


    /**
     * 修改数据
     *
     * @param role 实例对象
     * @return 实例对象
     */
    @UpdateAnn
    @Override
    public Role update(Role role) {
        roleDao.update(role);
        return role;
    }

    /**
     * 通过主键删除数据
     *
     * @return 是否成功
     */
    @Override
    public boolean delete(List list) {
        return roleDao.delete(list);
    }
}
